const express = require("express")

const app = express()

const path = require('path')

app.use(express.static(path.resolve(__dirname,"./public")))

// 引入中间件 解析post请求
// {extended：true} 表示深层解析
app.use(express.urlencoded({extended: true}))
app.post("/login",(req,res) => {
    console.log(req.body);
    if(req.body.username == "admin"&& req.body.password =="111111"){
    res.send(`<h1>${req.query.username},欢饮登录`)
    }else{
        res.send("<h1>用户名或密码错误</h1>")
    }
})

app.listen(4399,() => {
    console.log("启动成功 \n ---> http://localhost:4399/  \n --->http://127.0.0.1:4399")
})
